import numpy as np


# error code
ACL_SUCCESS = 0

# rule for mem
ACL_MEM_MALLOC_HUGE_FIRST = 0
ACL_MEM_MALLOC_HUGE_ONLY = 1
ACL_MEM_MALLOC_NORMAL_ONLY = 2

# rule for memory copy
ACL_MEMCPY_HOST_TO_HOST = 0
ACL_MEMCPY_HOST_TO_DEVICE = 1
ACL_MEMCPY_DEVICE_TO_HOST = 2
ACL_MEMCPY_DEVICE_TO_DEVICE = 3

# images format
IMG_EXT = ['.jpg', '.JPG', '.png', '.PNG', '.bmp', '.BMP', '.jpeg', '.JPEG']

# models format
MODEL_EXT = [".om"]

# numpy data type
NPY_BOOL = 0
NPY_BYTE = 1
NPY_UINT8 = 2
NPY_INT16 = 3
NPY_UINT16 = 4
NPY_INT32 = 5
NPY_UINT32 = 6
NPY_INT64 = 7
NPY_UINT64 = 8
NPY_FLOAT32 = 11
NPY_DOUBLE = 12
NPY_FLOAT16 = 23


def numpy_to_acl(dtype):
    if dtype == np.uint8:
        return NPY_UINT8
    elif dtype == np.int8:
        return NPY_BYTE
    elif dtype == np.int16:
        return NPY_INT16
    elif dtype == np.uint16:
        return NPY_UINT16
    elif dtype == np.int32:
        return NPY_INT32
    elif dtype == np.uint32:
        return NPY_UINT32
    elif dtype == np.int64 or dtype == np.int:
        return NPY_INT64
    elif dtype == np.uint64 or dtype == np.uint:
        return NPY_UINT64
    elif dtype == np.float16 or dtype == np.half:
        return NPY_FLOAT16
    elif dtype == np.float32:
        return NPY_FLOAT32
    elif dtype == np.float or dtype == np.float64:
        return NPY_DOUBLE



